from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.admins import AdminSerializer
from meiduo_admin.serializers.groups import GroupSerializer
from meiduo_admin.utils import PageNum
from users.models import User
from django.contrib.auth.models import Group

class AdminView(ModelViewSet):
    queryset = User.objects.filter(is_staff=True)
    serializer_class = AdminSerializer
    pagination_class = PageNum
    permission_classes = [IsAdminUser]

    # 获取分组的简单信息
    def simple(self,request):
        # 获取信息
        group=Group.objects.all()
        # 指定序列化器
        ser=GroupSerializer(group,many=True)
        return Response(ser.data)